/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package sk.stancel.peter.sudoku.core;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 *
 * @author Peter Stancel
 */
public class Tile implements Serializable {

	private static final long serialVersionUID = -1908602961773571621L;
	/** Necessary for generatin field. */
    private List<Integer> numbers = new ArrayList<Integer>();
    /** Value of tile. */
    private int value = 0;
    /** It is true if value of tyle can be changed. */
    private boolean change = true;
    /** Every tile has field of hints. */
    private Hint[] hints;
    
    public Tile(Integer value, boolean isPlayTiles) {
        this.value = value;
        if(isPlayTiles){
        	hints = new Hint[9];
            createHints();
        }
    }

    /**
     * Returns the value.
     * @return the value
     */
    public int getValue() {
        return value;
    }

    /**
     * Sets the value.
     * @param value the value to set
     */
    public void setValue(int value) {
        this.value = value;
    }

    /**
     * Genetares random number from 1 to 9.
     * @return random number from 1 to 9
     */
    public int getRandomNumber() {
        if (numbers.size() == 0) {
            for (int i = 1; i < 10; i++) {
                numbers.add(i);
            }
        }
        Random rnd = new Random();
        return numbers.remove(rnd.nextInt(numbers.size()));
    }

    /**
     * Sets the change.
     * @param change the change to set
     */
    public void setChange(boolean change) {
        this.change = change;
    }

    /**
     * Returns the change.
     * @return the change
     */
    public boolean isChange() {
        return change;
    }

    /**
     * Creates hints.
     */
    private void createHints() {
        for (int hintNumber = 1; hintNumber < 10; hintNumber++) {
            hints[hintNumber - 1] = new Hint(hintNumber);
        }
    }

    /**
     * Returns the hints.
     * @return the hints
     */
    public Hint[] getHints() {
        return hints;
    }
}
